package chapter2.No2_2_synchronized同步语句块.o内置类与同步_实验2;

import chapter2.No2_2_synchronized同步语句块.o内置类与同步_实验2.PublicClass.*;

/**
 * *：
 *      1. methodA和methodC都是得到的是StaticClass类的同一个对象锁，所以他们是同步的
 *      2. 而methodB得到的是PrivateClass类的对象锁，所以和他们是异步的
 *
 */
public class Main {

    public static void main(String[] args) {
        final StaticClass staticClass = new StaticClass();
        final PrivateClass privateClass = new PrivateClass();

        Thread a = new Thread(new Runnable() {
            public void run() {
                privateClass.methodA(staticClass);
            }
        }, "A");

        Thread b = new Thread(new Runnable() {
            public void run() {
                privateClass.methodB();
            }
        }, "B");

        Thread c = new Thread(new Runnable() {
            public void run() {
                staticClass.methodC();
            }
        }, "C");

        a.start();
        b.start();
        c.start();

    }

}
